<cfcomponent output="false">
	
	<!--- --->
	
	<cffunction name="initCraftivity" access="public" output="false" returntype="any">
		<cfargument name="initSite" required="true" />
		
		<cfset var local = {} />
		
		<!--- keep threads --->
		<cfset local.threads = [] />
		<cfif structKeyExists(application,"threads")>
			<cfset local.threads = application.threads />
		</cfif>

		<cfset application.applicationname = "craftivity" />
		<cfset application.name = "craftivity" />
		<cfset application.core = this />
		<cfset application.path = "" />
		<cfset application.cfcpath = "" />
		<cfset application.threads = local.threads />
		
		<cfset initVars() />

		<!--- toggle user visible errors --->
		<cfif cgi.request_url contains 'localhost'>
			<cfset application.devmode = "true" />
		<cfelse>
			<cfset application.devmode = "false" />
		</cfif>	

		<!--- toggle whether to link to online libraries --->
		<cfset application.online = "true" />
		<cfset application.sessionTimeout = 100000 /> <!--- a long time --->

		<cfset initHelpers() />
		<cfset initServices("craftivity,resource,worksheet,calendar,google,googleAPI,important,discussion,log,option,email,goal,workweek") />
		<cfset initGateways("craftivity,resource,worksheet,calendar,important,discussion,log,option,goal,workweek") />
		<cfset initViews("hopscotch,left,craftivity,worksheet,calendar,important,setup,discussion,log,option,goal,workweek") />
		<cfset initControllers("craftivity,worksheet,calendar,discussion,log,option,goal,workweek") />
		
		<cfset application.session = createObject("component","cfcs.Session") />
		<cfset application.global = createObject("component","cfcs.global") />
		<cfset initGlobal() />
		<cfset application.session.init() />

		<!--- <cfset application.s3 = createObject('component',"cfcs.s3").init(application.helpers.site.getVar('AWSaccessKeyID'),application.helpers.site.getVar('AWSaccessKeySecret')) /> --->

		<!--- check session --->
		<!--- <cfset application.s.sessionService.setClientID() />
		<cfset application.s.sessionService.evaluateSession() /> --->
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="initServices" access="private" output="false" returntype="void">
		<cfargument name="names" required="true" />
		
		<cfset var local = {} />
		
		<cfloop list="#arguments.names#" index="local.name">
			<cfset application.s['#local.name#Service'] = createObject('component','#application.cfcpath#cfcs.services.#local.name#Service') />
		</cfloop>

	</cffunction>
	
	<!--- --->
	
	<cffunction name="initGateways" access="private" output="false" returntype="void">
		<cfargument name="names" required="true" />
		
		<cfset var local = {} />
		
		<cfloop list="#arguments.names#" index="local.name">
			<cfset application.g['#local.name#Gateway'] = createObject('component','#application.cfcpath#cfcs.gateways.#local.name#Gateway') />
		</cfloop>

	</cffunction>
	
	<!--- --->
	
	<cffunction name="initViews" access="private" output="false" returntype="void">
		<cfargument name="names" required="true" />
		
		<cfset var local = {} />
		
		<cfloop list="#arguments.names#" index="local.name">
			<cfset application.v['#local.name#View'] = createObject('component','#application.cfcpath#cfcs.views.#local.name#View') />
		</cfloop>

	</cffunction>
	
	<!--- --->
	
	<cffunction name="initControllers" access="private" output="false" returntype="void">
		<cfargument name="names" required="true" />
		
		<cfset var local = {} />
		
		<cfloop list="#arguments.names#" index="local.name">
			<cfset application.c['#local.name#Controller'] = createObject('component','#application.cfcpath#cfcs.controllers.#local.name#Controller') />
		</cfloop>

	</cffunction>
	
	<!--- --->
	
	<cffunction name="initHelpers" access="private" output="false" returntype="void">
		
		<cfset application.helpers = {} />
		<cfset application.helpers.database = createObject('component','#application.cfcpath#cfcs.helpers.database') />
		<cfset application.helpers.date = createObject('component','#application.cfcpath#cfcs.helpers.date') />
		<cfset application.helpers.format = createObject('component','#application.cfcpath#cfcs.helpers.format') />
		<cfset application.helpers.page = createObject('component','#application.cfcpath#cfcs.helpers.page') />
		<cfset application.helpers.render = createObject('component','#application.cfcpath#cfcs.helpers.render') />
		<cfset application.helpers.request = createObject('component','#application.cfcpath#cfcs.helpers.request') />
		<cfset application.helpers.site = createObject('component','#application.cfcpath#cfcs.helpers.site') />
		<cfset application.helpers.valid = createObject('component','#application.cfcpath#cfcs.helpers.valid') />
		<cfset application.helpers.link = createObject('component','#application.cfcpath#cfcs.helpers.link') />
		<cfset application.helpers.util = createObject('component','#application.cfcpath#cfcs.helpers.util') />
		<cfset application.helpers.log = createObject('component','#application.cfcpath#cfcs.helpers.log') />
		<cfset application.helpers.run = createObject('component','#application.cfcpath#cfcs.helpers.run') />
	</cffunction>
	
	<!--- --->
	
	<cffunction name="includeScripts" access="public" output="false" returntype="string">
		<cfargument name="craftivity" required="false" default="false" />
		
		<cfset var local = {} />
		
		<cfsavecontent variable="local.result">
			<cfoutput>
				<cfif application.online>
					<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' rel='stylesheet' type='text/css'>
					<link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" rel="stylesheet">
				</cfif>
				<!--- google api --->
				<cfif application.online>
					<!--- <script>
				      function appendResults(text) {
				        var results = document.getElementById('results');
				        results.appendChild(document.createElement('P'));
				        results.appendChild(document.createTextNode(text));
				      }
				
				      function makeRequest() {
				        var request = gapi.client.urlshortener.url.get({
				          'shortUrl': 'http://goo.gl/fbsS'
				        });
				        request.execute(function(response) {
				          appendResults(response.longUrl);
				        });
				      }
				
				      function load() {
				        gapi.client.setApiKey('#$.site.getVar('api_key')#');
				        gapi.client.load('urlshortener', 'v1', makeRequest);
				      }
				      
				      function auth() {
				        var config = {
				    		client_id: '#$.site.getVar('google_client_id')#',
				          	scope: ['https://www.googleapis.com/auth/calendar','https://www.googleapis.com/auth/tasks']
				        };
				        gapi.auth.authorize(config, function() {
				          console.log('google login complete');
				          $(document).trigger('gconnect');
				          console.log(gapi.auth.getToken());
				        });
				      }
							    
					</script> --->
				    <script src="https://apis.google.com/js/client.js?onload=load" defer="defer"></script>
						
					<!--- google analytics --->
					<script>
						(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
						(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
						m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
						})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
						
						ga('create', 'UA-47445062-1', 'craftivity.me');
						ga('send', 'pageview');
					</script>
				</cfif>
				
				<!--- facebook ui --->
				<!--- <cfif not arguments.craftivity>
					<script>
					  window.fbAsyncInit = function() {
					    // init the FB JS SDK
					    FB.init({
					      appId      : '#$.site.getVar("app_id")#',  // App ID from the app dashboard
					      status     : true,                         // Check Facebook Login status
					      cookie	 : true,
					      xfbml      : true                          // Look for social plugins on the page
					    });
					
					    // Additional initialization code such as adding Event Listeners goes here
					  };
					
					  // Load the SDK asynchronously
					  (function(d){
					   var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
					   if (d.getElementById(id)) {return;}
					   js = d.createElement('script'); js.id = id; js.async = true;
					   js.src = "//connect.facebook.net/en_US/all.js";
					   ref.parentNode.insertBefore(js, ref);
					  }(document));
					
					  // Here we run a very simple test of the Graph API after login is successful. 
					  // This testAPI() function is only called in those cases. 
					  function testAPI() {
					    console.log('Welcome!  Fetching your information.... ');
					    FB.api('/me', function(response) {
					      console.log('Good to see you, ' + response.name + '.');
					    });
					  }
					</script>
				</cfif> --->
				
				<!--- end facebook ui --->
				
				<link rel="stylesheet" href="#application.path#/assets/css/jquery-ui-1.10.1.custom.css">
				<script type="text/javascript" src="#application.path#/assets/js/libraries/jquery-2.1.0.min.js"></script>
				<script type="text/javascript" src="#application.path#/assets/js/libraries/jquery-ui-1.10.4.custom.min.js"></script>
				<!--- <script type="text/javascript" src="#application.path#/assets/js/libraries/jquery.slides.min.js"></script>
				<script type="text/javascript" src="#application.path#/assets/js/libraries/jquery.placeholder.js"></script> --->
				<!--- <script type="text/javascript" src="#application.path#/assets/js/libraries/jquery.prettyPhoto.js"></script>
				<script type="text/javascript" src="#application.path#/assets/js/libraries/jquery.slimscroll.js"></script> --->
				<!--- <link rel="stylesheet" href="#application.path#/assets/css/prettyPhoto.css?#application.version#"> --->

				<script type="application/javascript">
					var clientIP = "";
				</script>
				
				<!--- craftvitiy CSS --->
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/kalendar.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/base.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/layout.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-center.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-left.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/radio.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/buttons.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-worksheet.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-calendar.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-workweek.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/ui.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/module-goals.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/datepicker.css?#application.version#">
				<link rel="stylesheet" href="#application.path#/craftivity/assets/css/hopscotch.css?#application.version#">

				<!--- craftivity JS --->
				<cfset local.js = [
					"kalendar.js",
					"helpers.js",
					"craftivity.js",
					"radio.js",
					<!--- "modal.js", ---> <!--- unused? --->
					"worksheet.js",
					"calendar.js",
					"ajax.js",
					"timepicker.js",
					"placeholder.js",
					"important.js",
					"timezone.js",
					"validateWords.js",
					"validate.js",
					"valid.js",
					"clock.js",
					"feedback.js",
					"url.js",
					"workweek.js",
					"cookie.js",
					"dateTime.js",
					"userActivity.js",
					"browserDetect.js",
					"dynamicRow.js",
					"goals.js",
					"bootstrap-datepicker.js",
					"touch.js",
					"hoverBubble.js",
					"hopscotch.js",
					"hopscotchTours.js",
					"froogaloop.js",
					"secretary.js"
				] />
				<cfloop array="#local.js#" item="local.item" index="local.i">
					<script type="text/javascript" src="#application.path#/craftivity/assets/js/#local.item#?#application.version#"></script>
				</cfloop>

			</cfoutput>
		</cfsavecontent>
		
		<cfreturn local.result />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="initVars" access="public" output="false" returntype="void">
		
		<cfset application.vars = {} />
		<!--- <cfset application.vars.localpong = {} />
		<cfset application.vars.webpong = {} />
		<cfset application.vars.localfundr = {} />
		<cfset application.vars.webfundr = {} /> --->
		<cfset application.vars.localcraftivity = {} />
		<cfset application.vars.webcraftivity = {} />
		
		<cfset application.version = "1.4.7" />
		
		<!--- <Cfset application.userLimit = 253 /> --->
		<cfset application.userLimit = 277 />
		
		<!--- localfundr --->
		<!--- <cfset application.vars.localfundr.app_id = '163131223886885' />
		<cfset application.vars.localfundr.app_secret = '18deed12bc45bd952086bd44fe05a41f' />
		<cfset application.vars.localfundr.encryptKey = 'ru8femXhTm9jwdGd1234232352345xx22' />
		<cfset application.vars.localfundr.rootPath = '' />
		<cfset application.vars.localfundr.rootURL = 'https://localhost:8443' />
		<cfset application.vars.localfundr.homeURL = '#application.vars.localfundr.rootURL#/home.cfm' />
		<cfset application.vars.localfundr.uploadURL = '#application.vars.localfundr.rootURL#/upload.cfm?' />
		<cfset application.vars.localfundr.my_url = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?cfc=loginController&method=handleFacebookLogin' />
		<cfset application.vars.localfundr.remote = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?' />
		<cfset application.vars.localfundr.AWSaccessKeyID = 'AKIAJBZNJ2EZXTDOEQNQ' />
		<cfset application.vars.localfundr.AWSaccessKeySecret = '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' />
		<cfset application.vars.localfundr.AWSpolicy = '{"expiration":"2014-01-01T00:00:00Z","conditions":[{"bucket":"FundrImages"},["eq", "$Content-Type", "image/jpeg"],["starts-with", "$key", ""],{"acl":"public-read"},{"success_action_redirect":"#application.vars.localfundr.uploadURL#"},["content-length-range",0,1048576]]}' />
		<cfset application.vars.localfundr.datasource = 'fundrdb' /> --->
		
		<!--- local craftivity --->
		<cfset application.vars.localcraftivity.google_redirect_uri = 'https://localhost:8443/cfcs/google_calendar.cfm' />
		<cfset application.vars.localcraftivity.google_email_address = '491115081363-jl4bbisndab5qgb3amgcku2rtffpmir5@developer.gserviceaccount.com' />
		<cfset application.vars.localcraftivity.google_client_secret = '9mDQJKo45IpZlcfKGWf_K7SF' />
		<cfset application.vars.localcraftivity.google_client_id = '491115081363-jl4bbisndab5qgb3amgcku2rtffpmir5.apps.googleusercontent.com' />
		<!--- <cfset application.vars.localcraftivity.google_email_address = '491115081363-4qe53qnq69hlhm083jqgv1abivfqfgbk@developer.gserviceaccount.com' />
		<cfset application.vars.localcraftivity.google_client_secret = 'W3D-8BlxfI6hrek9kyAp-gXO' />
		<cfset application.vars.localcraftivity.google_client_id = '491115081363-4qe53qnq69hlhm083jqgv1abivfqfgbk.apps.googleusercontent.com' /> --->
		<cfset application.vars.localcraftivity.api_key = 'AIzaSyBKKwcm-gdDwZPRi2Qwtuth3ag06XmvfnI' />
		<cfset application.vars.localcraftivity.app_id = '163131223886885' />
		<cfset application.vars.localcraftivity.app_secret = '18deed12bc45bd952086bd44fe05a41f' />
		<cfset application.vars.localcraftivity.encryptKey = 'ru8femXhTm9jwdGd1234232352345xx22' />
		<cfset application.vars.localcraftivity.rootPath = '' />
		<cfset application.vars.localcraftivity.rootURL = 'https://localhost:8443' />
		<!--- <cfset application.vars.localcraftivity.homeURL = '#application.vars.localfundr.rootURL#/home.cfm' />
		<cfset application.vars.localcraftivity.uploadURL = '#application.vars.localfundr.rootURL#/upload.cfm?' />
		<cfset application.vars.localcraftivity.my_url = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?cfc=loginController&method=handleFacebookLogin' />
		<cfset application.vars.localcraftivity.remote = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?' /> --->
		<cfset application.vars.localcraftivity.AWSaccessKeyID = 'AKIAJBZNJ2EZXTDOEQNQ' />
		<cfset application.vars.localcraftivity.AWSaccessKeySecret = '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' />
		<!--- <cfset application.vars.localcraftivity.AWSpolicy = '{"expiration":"2014-01-01T00:00:00Z","conditions":[{"bucket":"FundrImages"},["eq", "$Content-Type", "image/jpeg"],["starts-with", "$key", ""],{"acl":"public-read"},{"success_action_redirect":"#application.vars.localfundr.uploadURL#"},["content-length-range",0,1048576]]}' /> --->
		<cfset application.vars.localcraftivity.datasource = 'craftdb' />
		
		<!--- web craftivity --->
		<cfset application.vars.webcraftivity.google_redirect_uri = 'https://www.craftivity.me/cfcs/google_calendar.cfm' />
		<cfset application.vars.webcraftivity.google_email_address = '491115081363-jl4bbisndab5qgb3amgcku2rtffpmir5@developer.gserviceaccount.com' />
		<cfset application.vars.webcraftivity.google_client_secret = '9mDQJKo45IpZlcfKGWf_K7SF' />
		<cfset application.vars.webcraftivity.google_client_id = '491115081363-jl4bbisndab5qgb3amgcku2rtffpmir5.apps.googleusercontent.com' />
		<cfset application.vars.webcraftivity.api_key = 'AIzaSyBKKwcm-gdDwZPRi2Qwtuth3ag06XmvfnI' />
		<cfset application.vars.webcraftivity.app_id = '163131223886885' />
		<cfset application.vars.webcraftivity.app_secret = '18deed12bc45bd952086bd44fe05a41f' />
		<cfset application.vars.webcraftivity.encryptKey = 'ru8femXhTm9jwdGd1234232352345xx22' />
		<cfset application.vars.webcraftivity.rootPath = '' />
		<cfset application.vars.webcraftivity.rootURL = 'https://www.craftivity.me' />
		<!--- <cfset application.vars.webcraftivity.homeURL = '#application.vars.localfundr.rootURL#/home.cfm' />
		<cfset application.vars.webcraftivity.uploadURL = '#application.vars.localfundr.rootURL#/upload.cfm?' />
		<cfset application.vars.webcraftivity.my_url = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?cfc=loginController&method=handleFacebookLogin' />
		<cfset application.vars.webcraftivity.remote = '#application.vars.localfundr.rootURL#/cfcs/action.cfm?' /> --->
		<cfset application.vars.webcraftivity.AWSaccessKeyID = 'AKIAJBZNJ2EZXTDOEQNQ' />
		<cfset application.vars.webcraftivity.AWSaccessKeySecret = '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' />
		<!--- <cfset application.vars.webcraftivity.AWSpolicy = '{"expiration":"2014-01-01T00:00:00Z","conditions":[{"bucket":"FundrImages"},["eq", "$Content-Type", "image/jpeg"],["starts-with", "$key", ""],{"acl":"public-read"},{"success_action_redirect":"#application.vars.localfundr.uploadURL#"},["content-length-range",0,1048576]]}' /> --->
		<cfset application.vars.webcraftivity.datasource = 'craftdblive' />

		<!--- TWILIO --->
		<cfset application.vars.webcraftivity.twilio_sid = 'ACa92a64d720ce5ec43fa71482affe11f6' />
		<cfset application.vars.webcraftivity.twilio_token = 'ea45bcbb77c7a8dc74deeb5797bb50d9' />
		<cfset application.vars.localcraftivity.twilio_sid = 'ACa92a64d720ce5ec43fa71482affe11f6' />
		<cfset application.vars.localcraftivity.twilio_token = 'ea45bcbb77c7a8dc74deeb5797bb50d9' />

		<!--- identify database table settings --->
		<cfset application.vars.db = {} />
		<cfset application.vars.db.user = {name:"user",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund = {name:"fund",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment = {name:"payment",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment_method = {name:"payment_method",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment_status = {name:"payment_status",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment_account = {name:"payment_account",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment_activity = {name:"payment_activity",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.payment_plan = {name:"payment_plan",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.session = {name:"session",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.client = {name:"client",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund_key = {name:"fund_key",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund_favorite = {name:"fund_favorite",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund_contact = {name:"fund_contact",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund_mailing = {name:"fund_mailing",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.fund_mailing_history = {name:"fund_mailing_history",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.business = {name:"business",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.worksheet = {name:"worksheet",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.worksheet_field = {name:"worksheet_field",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.worksheet_field_user = {name:"worksheet_field_user",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.event = {name:"event",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.important = {name:"important",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.discussion = {name:"discussion",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.discussion_user = {name:"discussion_user",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.discussion_message = {name:"discussion_message",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.discussion_message_user_read = {name:"discussion_message_user_read",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.craftivity_log = {name:"craftivity_log",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.signup_email = {name:"signup_email",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.goal = {name:"goal",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.goal_milestone = {name:"goal_milestone",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.goal_action = {name:"goal_action",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.workweek_event = {name:"workweek_event",auto:"true",active:"true",timestamp:"true"} />
		<cfset application.vars.db.user_email_log = {name:"user_email_log",auto:"true",active:"true",timestamp:"true"} />
	</cffunction>
	
	<!--- --->
	
	<cffunction name="initGlobal" access="public" output="false" returntype="void">
		
		<cfset var local = {} />
		
		<!--- attach global to gateways --->
		<cfloop collection="#application.g#" item="local.item">
			<cfset application.g[local.item].$ = application.helpers />
		</cfloop>
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="populateSite" access="public" output="false" returntype="void">
		
		<cfset var local = {} />
				
		<cfset local.user1ID = application.s.userService.createUser(
			email="david@fundr.us",
			password="welcome",
			first_name="David",
			last_name="Schmavid",
			city="Houston",
			state_id='05c5a0feb20911e292cf1231390eb429',
			zip="41231"
		) />
		
		<cfset local.user2ID = application.s.userService.createUser(
			email="test@fundr.us",
			password="welcome",
			first_name="James",
			last_name="Dames",
			city="Indianapolis",
			state_id='b5e72652b20811e292cf1231390eb429',
			zip="12323"
		) />
		
		<cfset local.user3ID = application.s.userService.createUser(
			email="sarah@fundr.us",
			password="welcome",
			first_name="Sarah",
			last_name="Farrah",
			city="Salt Lake City",
			state_id='092b392ab20911e292cf1231390eb429',
			zip="12323"
		) />
		
		<cfset local.user4ID = application.s.userService.createUser(
			email="amy@fundr.us",
			password="welcome",
			first_name="Amy",
			last_name="Jamie",
			city="Minneapolis",
			state_id='cf1f7156b20811e292cf1231390eb429',
			zip="51234"
		) />
		
		<cfset local.user5ID = application.s.userService.createUser(
			email="chris@fundr.us",
			password="welcome",
			first_name="Chris",
			last_name="Priss",
			city="Madison",
			state_id='1409c118b20911e292cf1231390eb429',
			zip="54701"
		) />
		
		<cfset local.user6ID = application.s.userService.createUser(
			email="peter@fundr.us",
			password="welcome",
			first_name="Peter",
			last_name="Chang",
			city="Minneapolis",
			state_id='cf1f7156b20811e292cf1231390eb429',
			zip="54701"
		) />
		
		<!--- peter signs in --->
		<cfset application.s.userService.setSessionUser(local.user6ID) />
		<cfset application.s.sessionService.evaluateSession('asdf') />
				
		<!--- peter creates a fund --->
		<cfset local.fund1ID = application.s.fundService.saveFund(
			title="Sales Department Ping Pong Table",
			who="Peter Chang",
			description="HR has ok'd us for acquiring a Ping Pong table but we all need to chip in to make it happen. BYOP(bring your own paddles).",
			target=1400
		) />
		
		<!--- peter creates payment accounts --->
		<cfset local.peterPaymentAccount1ID = application.s.paymentService.savePaymentAccount(
			payment_method_id='2257D58B0A9611E39B3D020054746872',
			card_name="VISA Ending 1233",
			address_1="",address_2="",city="",state_id="",zip="",
			number=4321432143211233
		).message />
		<cfset local.peterPaymentAccount2ID = application.s.paymentService.savePaymentAccount(
			payment_method_id='2496ADFA0A9611E39B3D020054746872',
			card_name="SAVING 4321",
			address_1="",address_2="",city="",state_id="",zip="",
			account_number=4321432143214321
		).message />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund1ID,tags="work,sports,pingpong") />
		<cfset application.s.tagService.add('work') />
		<cfset application.s.tagService.add('sports') />
		<cfset application.s.tagService.add('pingpong') />
		
		<!--- peter creates a fund --->
		<cfset local.fund2ID = application.s.fundService.saveFund(
			title="Mom's Trip to the UK",
			who="Peter Chang",
			description="Mom has never been to the United Kingdom and the time is now! Lets help her reach her dream!",
			target=6500
		) />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund2ID,tags="travel,mom") />
		<cfset application.s.tagService.add('travel') />
		<cfset application.s.tagService.add('mom') />
		
		<!--- david signs in --->
		<cfset application.s.userService.setSessionUser(local.user1ID) />
		<cfset application.s.sessionService.evaluateSession() />
		
		<!--- david creates a fund --->
		<cfset local.fund3ID = application.s.fundService.saveFund(
			title="Bonnie's Cancer Fund",
			who="David Schmavid",
			description="Bonnie Johnson from Church was diagnosed with Cancer this year and just began her treatments. Her health insurance isn't enough to cover the treatments and leaves her family vulnerable. We hope you will all help."
		) />
		
		<!--- find fund key --->
		<cfquery name="local.fund3" datasource="fundrdb">
			select fund_key.fund_key
			from fund_key where fund_id = #application.helpers.database.uuid(local.fund3ID)#
		</cfquery>
		<cfset local.fund3Key = local.fund3.fund_key />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund3ID,tags="church,cancer,community") />
		<cfset application.s.tagService.add('church') />
		<cfset application.s.tagService.add('cancer') />
		<cfset application.s.tagService.add('community') />
		
		<!--- peter signs in --->
		<cfset application.s.userService.setSessionUser(local.user6ID) />
		<cfset application.s.sessionService.evaluateSession('asdf') />
		
		<!--- sets up payment plan for Bonnie's cancer fund --->
		<cfset local.args = {} />
		<cfset local.args.fundID=local.fund3key />
		<cfset local.args.amount=25 />
		<cfset local.args.date=application.helpers.date.getDate() />
		<cfset local.args.end_date = "" />
		<cfset local.args.total_amount = "" />
		<cfset local.args.message = "" />
		<cfset local.args.installments = "4" />
		<cfset local.args['anonymous_#local.fund3key#'] = 0 />
		<cfset local.args['frequency_#local.fund3key#'] = 2 />
		<cfset local.args['limit_#local.fund3key#'] = 1 />
		<cfset local.args['payment_account_id_#local.fund3key#'] = local.peterPaymentAccount1ID />

		<cfset application.s.paymentService.savePaymentPlan(argumentCollection=local.args) />
		
		<!--- favorites Bonnie's fund --->
		<cfset application.s.userService.addFavorite(local.fund3ID) />
		
		<!--- james signs in --->
		<cfset application.s.userService.setSessionUser(local.user2ID) />
		<cfset application.s.sessionService.evaluateSession() />
		
		<!--- james creates payment accounts --->
		<cfset local.jamesPaymentAccount1ID = application.s.paymentService.savePaymentAccount(
			payment_method_id='2257D58B0A9611E39B3D020054746872',
			card_name="MC Ending 5263",
			address_1="",address_2="",city="",state_id="",zip="",
			number=4321432143211233
		).message />
		
		<!--- sets up payment plan for Bonnie's cancer fund --->
		<cfset local.args.fundID=local.fund3key />
		<cfset local.args.amount=40 />
		<cfset local.args['payment_account_id_#local.fund3key#'] = local.jamesPaymentAccount1ID />

		<cfset application.s.paymentService.savePaymentPlan(argumentCollection=local.args) />
		
		<!--- favorites Bonnie's fund --->
		<cfset application.s.userService.addFavorite(local.fund3ID) />
		
		<!--- james creates a fund --->
		<cfset local.fund4ID = application.s.fundService.saveFund(
			title="My College Education!",
			who="James Dames",
			description="I've been accepted to the Bloomer Community College and I will attend September of 2014. Mom, Dad, Gramps and all other relatives. Please start pitching in to help with my tuition. If we reach $8,000 I vow to not touch a drop of liquor at college.",
			target=8000
		) />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund4ID,tags="college,education,family") />
		<cfset application.s.tagService.add('college') />
		<cfset application.s.tagService.add('education') />
		<cfset application.s.tagService.add('family') />
		
		<!--- sarah signs in --->
		<cfset application.s.userService.setSessionUser(local.user3ID) />
		<cfset application.s.sessionService.evaluateSession() />
		
		<!--- sarah creates payment accounts --->
		<cfset local.sarahPaymentAccount1ID = application.s.paymentService.savePaymentAccount(
			payment_method_id='2257D58B0A9611E39B3D020054746872',
			card_name="AMEX Ending 9959",
			address_1="",address_2="",city="",state_id="",zip="",
			number=4321432143211233
		).message />
		
		<!--- sets up payment plan for Bonnie's cancer fund --->
		<cfset local.args.fundID=local.fund3key />
		<cfset local.args.amount=10 />
		<cfset local.args['payment_account_id_#local.fund3key#'] = local.sarahPaymentAccount1ID />
		
		<!--- favorites Bonnie's fund --->
		<cfset application.s.userService.addFavorite(local.fund3ID) />
		
		<!--- sarah creates a fund --->
		<cfset local.fund5ID = application.s.fundService.saveFund(
			title="XBox One OMG",
			who="Sarah Farrah",
			description="Mom! Dad! The new Xbox comes out in November. Please oh please I've been so good this year, consider funding this effort and I'll totally share with you guys.",
			target=600
		) />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund5ID,tags="xbox,games,family") />
		<cfset application.s.tagService.add('xbox') />
		<cfset application.s.tagService.add('games') />
		<cfset application.s.tagService.add('family') />
		
		<!--- Amy signs in --->
		<cfset application.s.userService.setSessionUser(local.user4ID) />
		<cfset application.s.sessionService.evaluateSession() />
		
		<!--- favorites Bonnie's fund --->
		<cfset application.s.userService.addFavorite(local.fund3ID) />
		
		<!--- amy creates a fund --->
		<cfset local.fund6ID = application.s.fundService.saveFund(
			title="Pudge (my dog) needs intestinal surgery",
			who="Amy Pope",
			description="Pudge is a 3 yr old greyhound and my best friend. The vet needs to operate on him or he will need to be put down. Pudge is too young and too precious to part with.",
			target=3500
		) />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund6ID,tags="pets,dogs,illness") />
		<cfset application.s.tagService.add('pets') />
		<cfset application.s.tagService.add('dogs') />
		<cfset application.s.tagService.add('illness') />
		
		<!--- amy creates a fund --->
		<cfset local.fund7ID = application.s.fundService.saveFund(
			title="Starting Fantasy Football Business",
			who="Amy Pope",
			description="Fantasy Football is all the rage right now. I'm starting a venture to capitalize on this trend. I need startup capital for tshirts and legal counsel as well as some advertising to get started.",
			target=8500
		) />
		
		<!--- add tags --->
		<cfset application.helpers.database.save(table="fund",id=local.fund7ID,tags="sports,fantasyfootball,business") />
		<cfset application.s.tagService.add('sports') />
		<cfset application.s.tagService.add('fantasyfootball') />
		<cfset application.s.tagService.add('business') />
		
		<!--- log out --->
		<cfset application.s.userService.logout() />
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="clearSite" access="public" output="false" returntype="void">
		
		<cfset var local = {} />
		
		<!--- clear cookies, a part of populateSite() --->
		<cfcookie name="clientID" expires="#now()#" />
		<cfcookie name="clientKey" expires="#now()#" />
		
		<!--- delete all data --->
		<cfquery name="local.delete" datasource="fundrdb">
			delete from payment_activity;
		</cfquery><cfquery name="local.delete" datasource="fundrdb">
			delete from payment;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from payment_plan;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from payment_account;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from fund_key;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from fund_contact;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from fund_mailing;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from fund_favorite;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from fund;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from user;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from client;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from session;
		</cfquery>
		<cfquery name="local.delete" datasource="fundrdb">
			delete from tag;
		</cfquery>
		
	</cffunction>
	
	<!--- --->
	
	<cffunction name="renderRedirectError" access="public" output="false" returntype="string">
		
		<cfset var local = {} />
		
		<cfsavecontent variable="local.error">
			<div class="error-page-text" style="display:inline-block;position:static;margin:13px 5px 5px 5px;">
				<b>Oops, something went wrong</b>
				</br><i class="fa fa-frown-o"></i></br>
				<cfif not cgi.http_referer contains 'action.cfm' and cgi.http_referer neq "">
					with your last action at
					</br>
					<cfoutput>
						<a href="#cgi.http_referer#">#cgi.http_referer#</a></br>
					</cfoutput>
				</cfif>
				The development staff has been notified
				</br>and are looking for a solution
				</br></br>
				*we beg you for forgiveness*
			</div>
		</cfsavecontent>
		
		<cfreturn local.error />
		
	</cffunction>
	
	<!--- --->

</cfcomponent>